{% extends "../../main.html" %}

{% block title %}{{_("Create Hint")}}{% end %}

{% block header %}
<link rel="stylesheet" href="/static/css/markdown-toolbar.css" type="text/css" />
<script src="/static/js/libs/commonmark.min.js"></script>
<script src="/static/js/libs/markdown-toolbar.js"></script>
<script src="/static/js/pages/admin/create/hint.js"></script>
{% end %}

{% block content %}
{% from tornado.options import options %}
{% from models.Box import Box %}
<div class="container">
    <h1>
        <i class="fa fa-medkit"></i>
        {{_("Create Hint")}}{% if box %} &ndash; {{box.name}}{% end %}
    </h1>
    <br />
    {% if errors is not None and len(errors) != 0 %}
        {% for error in errors %}
        <div class="alert alert-error">
            <a class="close" data-dismiss="alert" href="#">&times;</a>
            <h4 class="alert-heading">{{_("ERROR")}}</h4>
            {{ error }}
        </div>
        {% end %}
    {% end %}
    <div class="well">
            <div class="row">
                <div class="span4">
                <form class="form-horizontal" action="/admin/create/hint" method="post">
                    {% raw xsrf_form_html() %}
                    <div class="control-group">
                        <label class="control-label" for="price">{{_("Cost")}}</label>
                        <div class="controls">
                            <input autofocus required id="price" name="price" min="0" type="number" placeholder="{% if options.banking %}{{_('$')}} {{_('Price')}}{% else %}{{_('Points')}}{% end %}"
                                    rel="popover"
                                    data-original-title="{{_('Cost')}}"
                                    data-content="{{_('The cost to take the hint.  Can be >= 0.')}}">
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label" for="description">{{_("Description")}}</label>
                        <div class="controls">
                            <textarea required class="toolbar" id="description" maxlength="1024" rows="5" name="description" type="text" maxlength="1024" placeholder="{{_('Hint')}}"
                                    rel="popover"
                                    data-original-title="{{_('Description')}}"
                                    data-html="true"
                                    data-content="{{_('This is the description')}} [Max: 1024 {{_('Characters')}}].<br/><br/>{{_('Supports')}} Markdown (GitHub Style)">
                            </textarea>
                        </div>
                    </div>
                    {% if not box %}
                        <div class="control-group">
                            <label class="control-label" for="box_uuid">{{_("Box")}}</label>
                            <div class="controls">
                                <select name="box_uuid">
                                    <option value=""></option>
                                    {% for thebox in Box.all() %}
                                        <option value="{{ thebox.uuid }}">{{ thebox.name }}</option>
                                    {% end %}
                                </select>
                            </div>
                        </div>
                    {% else %}
                        <input id="box_uuid" name="box_uuid" value="{{ box.uuid }}" type="hidden" />
                    {% end %}
                    {% if box %}
                        <div class="control-group">
                            <label class="control-label" for="flag_uuid">{{_("Flag")}}</label>
                            <div class="controls">
                                <select name="flag_uuid">
                                    <option value=""></option>
                                    {% for flag in box.flags %}
                                        <option value="{{ flag.uuid }}">{{ flag.name }}</option>
                                    {% end %}
                                </select>
                            </div>
                        </div>
                    {% end %}
                    <div class="control-group">
                        <div class="controls">
                            <button class="btn btn-primary" type="submit">{{_("Create Hint")}}</button>
                        </div>
                    </div>
                </form>
            </div>
            <div class="offset3 span4">
                {% if box %}
                <p>
                    <blockquote>
                        <small>
                            <strong>{{_("Box Hints")}}:</strong>
                            {{_("If the flag selection is left empty, the hint will be considered a Box Hint.")}}
                        </small>
                    </blockquote>
                </p>
                {% end %}
            </div>
        </div>
    </div>
</div>
{% end %}
